home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / AEreferenceTemplate.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  7.9 KB  |  296 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //    Alias|Wavefront Script File
  19. //
  20. //    Creation Date:    Dec 1, 1998
  21. //    Author:            rh
  22. //
  23. //    Procedure Name:
  24. //    AEreferenceTempate
  25. //
  26. //    Description Name;
  27. //    Creates the attribute editor controls for the reference node.
  28. //
  29. //    Input Value:
  30. //    nodeName
  31. //
  32. //    Output Value:
  33. //    None
  34. //
  35.  
  36.  
  37. global proc  AErefFilenameNew(string $nodeAttr)
  38. {
  39.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  40.     string     $attr = $buffer[1];
  41.  
  42.     setUITemplate -pst attributeEditorTemplate;
  43.     columnLayout ($attr+"Column");
  44.     setParent ..;
  45.     setUITemplate -ppt;
  46.  
  47.     AErefFilenameReplace($nodeAttr);
  48. }
  49.  
  50.  
  51. global proc  AErefFilenameReplace(string $nodeAttr)
  52. {
  53.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  54.     string     $attr = $buffer[1];
  55.  
  56.     setParent ($attr+"Column");
  57.  
  58.     string    $layoutName=`setParent -q`;
  59.     int     $oldCnt=`columnLayout -q -nch $layoutName`;
  60.     string    $dataAry[] = `listAttr -m $nodeAttr`;
  61.     int        $dataCnt = size($dataAry);
  62.  
  63.     for ($i = 0; $i < $dataCnt; $i++)
  64.     {
  65.         string    $value = `getAttr ($nodeAttr+"["+$i+"]")`;
  66.         string     $rowLayoutName = $attr+"Row"+$i;
  67.         string    $textFieldName = $attr+"Text"+$i;
  68.  
  69.         if ($i < $oldCnt)
  70.         {
  71.             textField -e -text $value $textFieldName;
  72.             connectControl $textFieldName ($nodeAttr+"["+$i+"]");
  73.         }
  74.         else
  75.         {
  76.             setUITemplate -pst attributeEditorTemplate;
  77.             rowLayout -nc 1 -cw1 348 $rowLayoutName;
  78.             textField -ed false -text $value $textFieldName;
  79.             connectControl $textFieldName ($nodeAttr+"["+$i+"]");
  80.             setParent ..;
  81.             setUITemplate -ppt;
  82.         }
  83.     }
  84.  
  85.     for ($i = $dataCnt; $i < $oldCnt; $i++)
  86.     {
  87.         string     $rowLayoutName = $attr+"Row"+$i;
  88.  
  89.         if (`rowLayout -exists $rowLayoutName`)
  90.         {
  91.             deleteUI -layout $rowLayoutName;
  92.         }
  93.     }
  94.  
  95.     setParent ..;
  96. }
  97.  
  98.  
  99. global proc  AErefConnectListNew(string $nodeAttr)
  100. {
  101.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  102.     string     $attr = $buffer[1];
  103.  
  104.     setUITemplate -pst attributeEditorTemplate;
  105.     columnLayout ($attr+"Column");
  106.     setParent ..;
  107.     setUITemplate -ppt;
  108.  
  109.     AErefConnectListReplace($nodeAttr);
  110. }
  111.  
  112.  
  113. global proc  AErefConnectListReplace(string $nodeAttr)
  114. {
  115.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  116.     string     $attr = $buffer[1];
  117.  
  118.     setParent ($attr+"Column");
  119.  
  120.     string    $layoutName=`setParent -q`;
  121.     int     $oldCnt=`columnLayout -q -nch $layoutName`;
  122.     string    $dataAry[] = `listAttr -m $nodeAttr`;
  123.     int        $dataCnt = size($dataAry) / 3;
  124.  
  125.     for ($i = 0; $i < $dataCnt; $i++)
  126.     {
  127.         string    $refAttr = `getAttr ($nodeAttr+"["+$i+"].ca")`;
  128.         string    $srcPlugAry[] = `listConnections -s true -d false -p true ($nodeAttr+"["+$i+"].c")`;
  129.         string    $dstPlugAry[] = `listConnections -s false -d true -p true ($nodeAttr+"["+$i+"].c")`;
  130.         string    $btnCmd;
  131.         string    $text;
  132.  
  133.         if (size($srcPlugAry))
  134.         {
  135.             $btnCmd = ("disconnectAttr "+$srcPlugAry[0]+" "+$nodeAttr+"["+$i+"].c; ");
  136.             $btnCmd += ("AErefConnectListReplace(\""+$nodeAttr+"\")");
  137.             $text = ($refAttr+" <- "+$srcPlugAry[0]);
  138.         }
  139.         else if (size($dstPlugAry))
  140.         {
  141.             $btnCmd = ("disconnectAttr "+$nodeAttr+"["+$i+"].c "+$dstPlugAry[0]+"; ");
  142.             $btnCmd += ("AErefConnectListReplace(\""+$nodeAttr+"\")");
  143.             $text = ($refAttr+" -> "+$dstPlugAry[0]);
  144.         }
  145.         else
  146.         {
  147.             $btnCmd = "";
  148.             $text = "";
  149.         }
  150.  
  151.         string     $rowLayoutName = $attr+"Row"+$i;
  152.         string    $btnName = $attr+"Btn"+$i;
  153.         string    $textFieldName = $attr+"Text"+$i;
  154.  
  155.         if ($i < $oldCnt)
  156.         {
  157.             button -e -c $btnCmd $btnName;
  158.             textField -e -text $text $textFieldName;
  159.         }
  160.         else
  161.         {
  162.             setUITemplate -pst attributeEditorTemplate;
  163.             rowLayout -nc 2 -ct2 right both $rowLayoutName;
  164.             button -l "Disconnect" -w 100 -c $btnCmd $btnName;
  165.             textField -ed false -text $text $textFieldName;
  166.             setParent ..;
  167.             setUITemplate -ppt;
  168.         }
  169.     }
  170.  
  171.     for ($i = $dataCnt; $i < $oldCnt; $i++)
  172.     {
  173.         string     $rowLayoutName = $attr+"Row"+$i;
  174.  
  175.         if (`rowLayout -exists $rowLayoutName`)
  176.         {
  177.             deleteUI -layout $rowLayoutName;
  178.         }
  179.     }
  180.  
  181.     setParent ..;
  182. }
  183.  
  184.  
  185. global proc  AErefMultiStrNew(string $nodeAttr)
  186. {
  187.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  188.     string     $attr = $buffer[1];
  189.  
  190.     setUITemplate -pst attributeEditorTemplate;
  191.     columnLayout ($attr+"Column");
  192.     setParent ..;
  193.     setUITemplate -ppt;
  194.  
  195.     AErefMultiStrReplace($nodeAttr);
  196. }
  197.  
  198.  
  199. global proc  AErefMultiStrReplace(string $nodeAttr)
  200. {
  201.     string    $buffer[]; tokenize($nodeAttr, ".", $buffer);
  202.     string     $attr = $buffer[1];
  203.  
  204.     setParent ($attr+"Column");
  205.  
  206.     string    $layoutName=`setParent -q`;
  207.     int     $oldCnt=`columnLayout -q -nch $layoutName`;
  208.     string    $dataAry[] = `listAttr -m $nodeAttr`;
  209.     int        $dataCnt = size($dataAry);
  210.  
  211.     for ($i = 0; $i < $dataCnt; $i++)
  212.     {
  213.         string    $value = `getAttr ($nodeAttr+"["+$i+"]")`;
  214.         string    $btnCmd = ("setAttr -type \"string\" "+$nodeAttr+"["+$i+"] \"\"");
  215.         string     $rowLayoutName = $attr+"Row"+$i;
  216.         string    $btnName = $attr+"Btn"+$i;
  217.         string    $textFieldName = $attr+"Text"+$i;
  218.  
  219.         if ($i < $oldCnt)
  220.         {
  221.             button -e -c $btnCmd $btnName;
  222.             textField -e -text $value $textFieldName;
  223.             connectControl $textFieldName ($nodeAttr+"["+$i+"]");
  224.         }
  225.         else
  226.         {
  227.             setUITemplate -pst attributeEditorTemplate;
  228.             rowLayout -nc 2 -ct2 right both $rowLayoutName;
  229.             button -l "Remove" -c $btnCmd -w 100 $btnName;
  230.             textField -ed false -text $value $textFieldName;
  231.             connectControl $textFieldName ($nodeAttr+"["+$i+"]");
  232.             setParent ..;
  233.             setUITemplate -ppt;
  234.         }
  235.     }
  236.  
  237.     for ($i = $dataCnt; $i < $oldCnt; $i++)
  238.     {
  239.         string     $rowLayoutName = $attr+"Row"+$i;
  240.  
  241.         if (`rowLayout -exists $rowLayoutName`)
  242.         {
  243.             deleteUI -layout $rowLayoutName;
  244.         }
  245.     }
  246.  
  247.     setParent ..;
  248. }
  249.  
  250.  
  251. global proc AEreferenceTemplate(string $nodeName)
  252. {
  253.     editorTemplate -beginScrollLayout;
  254.  
  255.         editorTemplate -beginLayout "File Names" -collapse true;
  256.         editorTemplate -callCustom "AErefFilenameNew" "AErefFilenameReplace" "fn";
  257.         editorTemplate -endLayout;
  258.     
  259.         editorTemplate -beginLayout "Connection List" -collapse true;
  260.         editorTemplate -callCustom "AErefConnectListNew" "AErefConnectListReplace" "cl";
  261.         editorTemplate -endLayout;
  262.     
  263.         editorTemplate -beginLayout "Set Attr List" -collapse true;
  264.         editorTemplate -callCustom "AErefMultiStrNew" "AErefMultiStrReplace" "sl";
  265.         editorTemplate -endLayout;
  266.     
  267.         editorTemplate -beginLayout "Add Attr List" -collapse true;
  268.         editorTemplate -callCustom "AErefMultiStrNew" "AErefMultiStrReplace" "al";
  269.         editorTemplate -endLayout;
  270.     
  271.         editorTemplate -beginLayout "Broken Connection List" -collapse true;
  272.         editorTemplate -callCustom "AErefMultiStrNew" "AErefMultiStrReplace" "bl";
  273.         editorTemplate -endLayout;
  274.     
  275.         editorTemplate -beginLayout "Parent List" -collapse true;
  276.         editorTemplate -callCustom "AErefMultiStrNew" "AErefMultiStrReplace" "pl";
  277.         editorTemplate -endLayout;
  278.  
  279.         // Include all base class and node attributes.
  280.         //
  281.         AEdependNodeTemplate  $nodeName;
  282.  
  283.     
  284.         // Suppressed attributes
  285.         editorTemplate -suppress "fileNames";
  286.         editorTemplate -suppress "connectionList";
  287.         editorTemplate -suppress "setAttrList";
  288.         editorTemplate -suppress "parentList";
  289.         editorTemplate -suppress "addAttrList";
  290.         editorTemplate -suppress "brokenConnectionList";
  291.  
  292.     editorTemplate -addExtraControls;
  293.     editorTemplate -endScrollLayout;
  294.  
  295. }
  296.